package com.lixm.netty.day2;

import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;

/**
 * @author dc
 * @title: TimeServer
 * @projectName netty
 * @date 2021/7/816:57
 */
public class TimeServer {
    // 默认端口
    private static Integer port = 8080;


    public static void main(String[] args) throws IOException {

        try {
            // 从别的地方传过来
            port = Integer.valueOf(args[0]);
        } catch (Exception e) {
            e.printStackTrace();
        }

        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(port);
            System.out.println("The timeServer start port :" + port);

            Socket socket;
            while (true) {
                socket = serverSocket.accept();
                new ServerThreadPool(10, 120).execute(new TimeServerHandle(socket));
            }
        } finally {

        }
    }
}
